
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;


namespace Tama_Chan.ParticleEngine_ns
{
   public class ParticleEffect : IParticleEffect
   {
      public bool IsDead { get; set; }
      private IList<IParticle> Particles { get; set; }


      public ParticleEffect(int numberOfParticles)
      {
         IsDead = false;
         Particles = new List<IParticle>(numberOfParticles);
      }

      public void AddParticle(IParticle particle)
      {
         Particles.Add(particle);
      }

      public void Update(GameTime gameTime)
      {
         // Update all particle's state
         for(int i=0; i<Particles.Count; i++)
         {
            Particles[i].Update(gameTime);
         }

         // If all are dead, this effect is dead
         IsDead = Particles.All(t => t.IsDead);
      }

      public void Draw()
      {
         for(int i = 0; i < Particles.Count; i++)
         {
            Particles[i].Draw();
         }
      }

   }
}
